// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
//引入echarts
import echarts from 'echarts'
//注册组件
Vue.prototype.$echarts = echarts

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
// axios.defaults.baseURL="http://192.168.60.95:9099"
axios.defaults.baseURL="http://localhost:9099"

// 添加请求拦截器
axios.interceptors.request.use(request=>{
  if(localStorage.getItem("ecologyToken")){
    request.headers["ecologyToken"] = localStorage.getItem("ecologyToken")
  }
return request;
});
// 添加响应拦截器
axios.interceptors.response.use(response=>{
  if(response.headers.ecologytoken){
   localStorage.setItem("ecologyToken",response.headers.ecologytoken)
  }
  if(response.data.code==401){
    router.push("/")
  }
  return response;
})

Vue.prototype.$http=axios
Vue.use(ElementUI);


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
